package com.example.kaogong.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.kaogong.sys.pojo.Paper;
import com.example.kaogong.sys.pojo.vo.PaperInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 试卷 Mapper 接口
 * </p>
 *
 * @author    
 * @since 2022-03-26
 */
@Mapper
public interface PaperMapper extends BaseMapper<Paper> {

    /**
     * 获取所有已发布试卷的基本信息
     * @return
     */
    List<PaperInfoVo> getAllPaperInfo(@Param("status") int status, @Param("tid") Integer tid);

    /**
     * 根据试卷编号获取试卷基本信息
     * @param paperId
     * @return
     */
    PaperInfoVo getPaperInfo(Integer paperId);

    /**
     * 逻辑删除试卷
     * @param paperId
     * @return
     */

    @Update({"update t_paper set deleted = 1 where paper_id = #{paperId}"})
    int deletePaperById(Integer paperId);

    @Update({"update t_paper set paper_status = 2 where paper_id = #{paperId}"})
    int publishPaperById(Integer paperId);

    int createPaper(Paper paper);
}
